struct Solution {}

fn main() {}

impl Solution {
    pub fn convert_to_base7(num: i32) -> String {
        if num == 0 {
            return "0".to_string();
        }
        let mut arr = vec![];
        let mut num_cp = num.abs();
        while num_cp > 0 {
            if num_cp < 7 {
                arr.push(num_cp);
                break;
            }
            arr.push(num_cp % 7);
            num_cp /= 7;
        }
        arr.reverse();
        let mut ret = arr.iter().map(|&e| e.to_string()).collect::<String>();
        if num < 0 {
            return "-".to_string() + &ret;
        }
        ret
    }
}